#ifndef SETTINGWIDGET_H
#define SETTINGWIDGET_H

#include <QButtonGroup>
#include <QHBoxLayout>
#include <QLine>
#include <QPushButton>
#include <QScreen>
#include <QStackedWidget>
#include <QTableWidgetItem>
#include <QThread>
#include <QWidget>
#include "settingWidget/videoWidget/videowidget.h"
#include <settingWidget/NetWorkDetection/netdetectionwidget.h>
#include <settingWidget/NetWorkDetection/netfinishedwidget.h>
extern QString styleSheetTempalte;

/**
 * @brief The settingWidget class 这个类就是登陆前点击设置按钮后出现的设置窗口
 */
class settingWidget : public QWidget
{
    Q_OBJECT
public:
    explicit settingWidget(QWidget *parent = nullptr);

private:
    void centerWindow();
    void setTableWidgetItem(QTableWidgetItem *item, const QString IconURL);
    void createQButtonGroup();
    void initStackWidget();
    void changeBtnIcon(int preIndex, int currentIndex);
    bool eventFilter(QObject *watch, QEvent *event) override;
    void startCameraInThread();
    void stopCameraInThread();
    void showEvent(QShowEvent *event) override;
private slots:
    void onButtonClicked(int id);
    void oncheckNetworkFinished(bool a, bool b, bool c, qint64 d, qint64 e);
    void onCheckNetworkAgain();

protected:
    void paintEvent(QPaintEvent *event) override;
    void mousePressEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;

private:
signals:
    void clearSetting();
    // void changeBtnIcon(int preIndex, int currentIndex);
    void stopSpeaker();
    void stopCheck();

private:
    QHBoxLayout *qHboxLayout; //这是顶端的水平布局
    QPushButton *btnClose;
    QPushButton *btnSetting;
    QPushButton *btnCamera;
    QPushButton *btnVoice;
    QPushButton *btnNet;
    QPushButton *btnKeyBoard;
    QPushButton *btnAbout;
    QButtonGroup *btnGroup;
    QStackedWidget *stackWidget;
    videoWidget *video;
    int preClickedButtonID; //这是前一个已经点击了的按钮的id
    QMap<QAbstractButton *, QPair<QString, QString>> buttonIconMap;
    bool m_dragging;
    QPoint m_offset;
    // uint8_t acitveBtnIndex;
    QAbstractButton *activeBtn;
    QMediaCaptureSession *captureSession;
    NetDetectionWidget *network1;
    NetFinishedWidget *netfinshed;
};

#endif // SETTINGWIDGET_H
